<extend name="work/base"/>
<block name="content">
    <form class="layui-form inline-form">
        <div class="pull-left">
            <div class="layui-inline dropdown">
                <input name="title" class="layui-input" type="text" id="title" placeholder="新闻标题">
            </div>
            <div class="layui-inline">
                <button class="layui-btn  layui-btn-normal" lay-submit lay-filter="search_btn"><i
                        class="layui-icon">&#xe615;</i>搜索
                </button>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layui-btn-normal  ajax-form"
                        data-url="{:url('site/news/add')}"><i
                        class="layui-icon">&#xe61f;</i> 新增
                </button>
            </div>
        </div>
    </form>
    <table class="layui-table text-center" id="list" lay-filter="list"
           list-url="{:url('site/news/lists')}"
           edit-url="{:url('site/news/add')}"
           del-url="{:url('site/news/delete')}"
    ></table>

</block>
<block name="script">
    <script charset="utf-8" src="https://cdn.weibuyun.com/static/admin/plugins/wangeditor/wangEditor.min.js"></script>
    <script charset="utf-8" src="https://unpkg.com/qiniu-js@2.5.4/dist/qiniu.min.js"></script>
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="applyinfo" info_id="{:url('site/news/view')}"><i
                class="fa fa-laptop"></i>查看</a>
        <a class="layui-btn  layui-btn-xs " lay-event="edit"><i class="fa fa-pencil"></i> 编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"> <i class="fa fa-trash-o"></i> 删除</a>
    </script>
    <script type="text/javascript">
        layui.use(['element', 'table', 'form', 'tree'], function () {
            var table = layui.table
                , element = layui.element
                , form = layui.form;
            table.render({
                elem: '#list'
                , url: "{:Url('site/news/lists')}"
                , page: true
                , limit: 20
                , cols: [[
                     {field: 'category_id', width: 100,title: '分类'}
                    , {field: 'title', title: '标题'}
                    , {field: 'c_time', width: 100, title: '显示时间'}
                    , {fixed: 'right', width: 200, title: '操作', toolbar: '#barDemo'}
                ]]
            });

            form.on('submit(search_btn)', function (data) {
                table.reload('list', {
                    url: "{:Url('site/news/lists')}"
                    , page: {
                        curr: 1
                    }
                    , where: data.field
                });
                return false;
            });

        });
    </script>
</block>